package com.heo.sso.demo.app2.controller;

import com.heo.sso.client.filter.LoginFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author 刘康
 * @Date 2020-11-03 9:28
 * @Description
 * @Revision
 **/
@Controller
@RequestMapping("/")
@Slf4j
public class MainController {

    @GetMapping("/")
    public String index(Model model, HttpServletRequest request) {
        String token = (String) request.getAttribute("token");
        String username = LoginFilter.redis.get(token);
        log.info("username: {}", username);
        log.info("~~~~~~~~~~~~~~~~");
        model.addAttribute("username", username);
        return "index";
    }
}
